package com.situation.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.situation.mapper.TbImageMapper;
import com.situation.pojo.DO.TbDepartment;
import com.situation.pojo.DO.TbImage;
import com.situation.service.TbImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author TaoMinghui
 * @create 2021-12-08 19:14
 */
@Service
public class TbImageServiceImpl implements TbImageService {

    @Autowired
    private TbImageMapper tbImageMapper;

    /**
     * 添加图片到tb_image
     * @param tbImage
     * @return
     */
    @Override
    public int addTbImage(TbImage tbImage) {
        return tbImageMapper.addTbImage(tbImage);
    }

    /**
     * 多条件分页模糊查询附件列表
     * @param pageNum
     * @param pageSize
     * @param tbImage
     * @return
     */
    @Override
    public PageInfo<TbImage> findImageListFenYeMoHu(int pageNum, int pageSize, TbImage tbImage) {
        PageHelper.startPage(pageNum,pageSize);
        List<TbImage> imageListFenYeMoHu = tbImageMapper.findImageListFenYeMoHu(tbImage);
        PageInfo<TbImage> tbImagePageInfo = new PageInfo<>(imageListFenYeMoHu);
        return tbImagePageInfo;
    }

    /**
     * 通过id删除一个附件图片
     * @param id
     * @return
     */
    @Override
    public int deleteImageById(int id) {
        return tbImageMapper.deleteImageById(id);
    }
}
